-
Notifications
You must be signed in to change notification settings - Fork 70
Feat/history #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RonStew2019
wants to merge
526
commits into
mpfaffenberger:main
Choose a base branch
from
RonStew2019:feat/history
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/history #54
+37,517
−2,323
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… and model switching - Update get_model_context_length() to respect agent-specific model pins via get_model_name() - Add graceful fallback to prevent status bar crashes if model config lookup fails - Ensure immediate agent reload when switching models in both CLI and TUI interfaces - Call refresh_config() for JSON agents before reload to pick up new model settings - Wrap reload operations in try-except to maintain stability during model changes
Add comprehensive attachment handling to enable users to drag files or paste URLs directly into prompts. The system automatically detects and processes images, PDFs, and other supported file types, passing them as binary content or URL references to the language model. - Implement `attachments.py` parser with shell-like tokenization to extract file paths and URLs from raw prompt text - Support local binary attachments (images: png/jpg/gif/webp, documents: pdf/txt/md) with MIME type detection - Support remote URL attachments (http/https image and document links) using pydantic-ai's ImageUrl/DocumentUrl types - Extend BaseAgent.run_with_mcp() to accept optional attachments and link_attachments parameters - Add run_prompt_with_attachments() helper in main.py to parse, validate, and execute prompts with attachments - Integrate attachment processing into both interactive mode and single-prompt execution flows - Provide user-friendly warnings for unsupported file types, missing files, or permission errors - Generate default prompt "Describe the attached files in detail" when user provides only attachments - Add comprehensive test coverage for parsing logic, file type detection, and integration with agent execution
Previously, BinaryContent objects in messages were silently skipped during string formatting, making it difficult to debug messages containing binary data. Now BinaryContent is explicitly marked in the formatted output.
Implement comprehensive handling of terminal drag-and-drop file paths that contain backslash-escaped spaces, ensuring reliable attachment detection and proper prompt cleaning across the command processing pipeline. - Introduce `_unescape_dragged_path()` to normalize backslash-space sequences before path resolution - Use sentinel markers to preserve escaped spaces during shlex tokenization in `_detect_path_tokens()` - Track token start indices in `_DetectedPath` for accurate span-based text replacement - Rebuild cleaned prompts using token-span logic to maintain exact punctuation and spacing - Update placeholder processor to use token spans for robust visual replacement with escaped paths - Parse attachments before command detection to prevent leading file paths from being misinterpreted as commands - Add test coverage for drag-and-drop escaped space handling - Remove unused `_clean_binaries()` method from base agent
- Disable POSIX mode in shlex.split() on Windows to prevent backslash escaping - Ensures Windows file paths with backslashes are correctly parsed as attachments - Fixes issue where backslashes in paths were being incorrectly interpreted as escape characters
- Remove document file type support (.pdf, .txt, .md) - Streamline media type detection to focus solely on images - Eliminate document-specific fallback logic in MIME type detection - Update function documentation to reflect image-only scope
- Add paginated display showing 5 sessions per page instead of fixed top-5 list - Replace single prompt with interactive loop supporting page navigation - Enable option 6 to cycle through pages or return to first page when at end - Preserve existing selection methods (numeric choice and direct name entry) - Improve user feedback with page-specific prompts and invalid selection warnings - Maintain backward compatibility with original session restoration behavior
…tory mutation - Remove URL detection from _parse_link to prevent URLs from being treated as attachments - URLs in prompts now remain as plain text instead of being converted to ImageUrl or DocumentUrl - Fix potential mutation bug in agent_manager by storing shallow copies of message histories - Prevent shared list instances between agent history cache and active agents - Update tests to reflect new behavior where URLs are left untouched in prompts
- Add persistent profile directory management to maintain browser state across runs - Configure Camoufox to use stored cookies, localStorage, and history via storage_state - Save browser context state on cleanup to preserve session data for future use - Display profile directory path in startup info and state save confirmation - Ensure profile directory is created if it doesn't exist at ~/.code_puppy/camoufox_profile
- Fix UsageLimits import to use public API instead of private module path - Downgrade pydantic-ai from 1.0.6 to 1.0.5 for stability - Refactor Camoufox browser initialization to use persistent context mode - Remove automatic homepage navigation to prevent duplicate tabs - Implement lazy page creation in get_current_page() method - Add persistent storage state handling for cookies and localStorage
| ) | ||
| return True | ||
|
|
||
| if command.startswith("/history"): |
Owner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Ronan - do you think you could refactor this nested functionality into its own thing, and then make this change in command_handler.py a 2-liner?
- Create code_puppy/command_line/history_command.py with MessageFormatter and HistoryCommand classes - Refactor command_handler.py to use 2-liner for /history command as requested in PR feedback - Maintain identical external functionality while improving internal structure - Apply SOLID principles: Single Responsibility and Dependency Inversion - Extract complex message formatting logic into reusable MessageFormatter class - Clean separation of concerns between parsing, formatting, and display Addresses PR feedback: 'refactor this nested functionality into its own thing, and then make this change in command_handler.py a 2-liner'
- Move /history implementation from command_handler.py to history_command.py - Add comprehensive argument parsing and error handling - Maintain full backward compatibility with all existing functionality - Fix function name typo in test imports (get_current_autosave_session_name) - Ensure all 8 history-related tests pass individually and as a group - Improve code organization with better separation of concerns - Enhance maintainability by isolating history logic in dedicated module Changed files: - code_puppy/command_line/history_command.py (new) - code_puppy/command_line/command_handler.py (refactor) - tests/test_command_handler.py (fix imports)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds /history command to display message history within current autosave session
Usage:
/history [N] [-v|--verbose]Features:
Nlimits displayed messages (e.g.,/history 5)-vdisplays full content without truncationNormal:
Verbose: